<link href="/public/src/china.css" type="text/css" rel="stylesheet"/>
<script src="<?php echo RESOURCE_SITE_URL;?>/js/area_array.js"></script>

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=P2FNtzxNufSlwBx3Gt3GYhxR"></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.js"></script>
<link rel="stylesheet" href="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.css" />
<style type="text/css">
    body {
        font-size: 12px;
        font-family: "宋体";
        line-height: 200%;
        margin: 0 auto;
        padding: 0;
        color: #939B98;
    }

    .channel {
        margin-top: 1px;
        padding: 10px 0;
        background: url(/public/src/images/chinabg.jpg) no-repeat 8px 11px #fff;
    }

    .list4 {
        border-bottom: none;
        overflow: hidden;
        width: 988px
    }

    .list4_1 {
        float: left;
        padding-top: 5px;
        margin: 8px 0 0 8px;
        width: 605px;
        height: 505px;
        overflow: hidden;
        position: relative;
    }

    .list4_2 {
        border: 1px #666 solid;
        margin-right: 10px;
        float: right;
        width: 343px;
        height: 265px;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .list4_2_1 {
        padding: 5px 5px 0px 10px;
        color: #626262;
        line-height: 21px;
        border-bottom: 1px solid #dddddd;
    }

    .list4_2_1 span {
        display: block;
        font-size: 16px;
        color: #f29098;
        padding: 5px 0
    }

    .menlist_title {
        margin: 15px 0;
        padding: 5px 10px 0px 10px;
        height: auto;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .menlist {
        height: 300px;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .content {
        padding: 15px 20px;
    }

    .postcontact td {
        padding: 8px 5px;
    }

    .postcontact .intxt {
        border: 1px solid #ccc;
        height: 25px;
    }

    .postcontact .np {
        margin-right: 5px;
        border: none;
    }

    .postcontact .coolbg {
        border: 1px solid #ccc;
        padding: 3px;
        text-align: center;
    }

    .articlebox {
        padding: 10px;
    }

    .map_list li {
        float: left;
        margin-left: 10px;
        margin-bottom: 8px;
        display: inline;
    }

    .map_1 {
        width: 686px;
        height: 419px;
        float: left;
        margin-left: 8px;
        margin-bottom: 10px;
        display: inline;
    }

    .map_2 {
        width: 276px;
        height: 419px;
        float: left;
        margin-left: 10px;
        margin-bottom: 10px;
        display: inline;
    }

    .map_3 {
        width: 448px;
        height: 147px;
        float: left;
        margin-left: 8px;
        display: inline;
    }

    .map_4 {
        width: 514px;
        height: 147px;
        float: left;
        margin-left: 10px;
        display: inline;
    }

    .menglist_title1 {
        background: url(/public/src/images/jiameng_bak.gif) no-repeat;
        color: #FFF;
        margin-left: 0;
        width: 86px;
        height: 21px;
        clear: both;
        text-align: center;
        margin-bottom: 5px;
    }

    /*搜索工具条*/
    .search {
        font-size: 14px;
        font-family: "微软雅黑", Arial;
        height: 36px;
        line-height: 36px;
        padding: 0 12px;
        color: white;
    }

    .search > div {
        height: 40px;
    }

    .search-left {
        width: 10px;
        background-image: url(/public/src/images/jiameng_search_left.png);
        float: left
    }

    .search-form {
        width: 956px;
        background-image: url(/public/src/images/jiameng_search_bg.gif);
        float: left
    }

    .search-form-province {
        margin: 0 22px
    }

    .search-form-city {
        margin-right: 62px;
    }

    .search-form-keyword {
        margin-right: 22px;
    }

    .search-form-bnt {
        height: 22px;
        top: 7px;
        position: relative;
    }

    .search-right {
        width: 10px;
        background-image: url(/public/src/images/jiameng_search_right.png);
        float: right
    }
    /*加盟商城市列表*/
    #menglist_rows{
        width:343px; height:auto; border:1px #000 solid; word-wrap:break-word;word-break:break-all;white-space: pre-wrap;
    }
    #menglist_rows a{
        padding: 0 4px;
    }
</style>
<!--当前位置 start-->
<div class="block box">
    <div id="ur_here">
        <img src="/public/src/images/category_icon.gif"/>&nbsp;当前位置：
        <?php $navLink = array();
        foreach ($output['nav_link_list'] as $item) { ?>
            <?php if (!empty($item['link'])) {
                $navLink[] = '<a href="' . $item['link'] . '">' . $item['title'] . '</a>';
            } else {
                $navLink[] = $item['title'];
            } ?>
        <? }
        echo implode(' &gt; ', $navLink); ?>
    </div>
</div>
<!--当前位置 end-->
<!--搜索 start-->
<div class="block box">
    <div class="search">
        <div class="search-left"></div>
        <div class="search-form" id="region">
            <form id="search-jiameng" onsubmit="return jiameng_search();">
                经销商详情查询
                <select name="province" id="search-province" class="search-form-province">
                    <option value="">请选择省份</option>
                </select>
                <select name="city" id="search-city" class="search-form-city">
                </select>
                输入关键字
                <input type="text" class="search-form-keyword" id="search-keyword" name="keyword"/>
                <input type="image" class="search-form-bnt" src="/public/src/images/jiameng_search_bnt.gif"/>
            </form>
        </div>
        <div class="search-right"></div>
    </div>
</div>
<!--搜索 end-->
<div style="margin:0 auto; width:1000px;overflow:hidden; font-family:'微软雅黑', Arial; font-size:13px;">
    <div class="channel">
        <div class="block">
            <div class="list4">
                <div class="list4_1" id="baidumap">
                </div>
                <div class="menlist_title">
                    <div class="menglist_title1">选择城市</div>
                    <div id="menglist_rows">

                    </div>
                </div>
                <div class="menlist">
                    <div class="menglist_title1" style="margin-left:10px;">江湖分舵</div>
         <span id="_stroelist">
          <div class='list4_2'>
              <?php if($output['franchiser']){
                  foreach($output['franchiser'] as $k=>$item){?>
                      <div class='list4_2_1' data-province="<?php echo $item['areaid_1'];?>" data-city="<?php echo $item['areaid_2'];?>" data-title="<?php echo $item['franchisee_name']=htmlspecialchars($item['franchisee_name']);?>">
                          <span>
                              <a href="<?php echo $item['article_id']?urlShop('article','show',array('article_id'=>$item['article_id'])):'#'?>" title="<?php echo $item['franchisee_name'];?>" class="f6">
                                  <?php echo $item['franchisee_name']; ?>
                              </a>
                          </span>
                          联系人：<?php echo htmlspecialchars($item['linkname']);?> <br>
                          电话：<?php echo htmlspecialchars($item['linkname_mobile']);?>
                      </div>
                  <?php }}?>
          </div>
          </span></div>
            </div>
        </div>
    </div>
    <div style="background:url(/public/src/images/jiameng_bak.gif) no-repeat; width:86px; height:21px; text-align:center; margin:0 auto; margin-bottom:5px; color:#fff; ">
        推荐商家
    </div>
    <div style="background:url(/public/src/images/tuijianjiameng.jpg) no-repeat; width:983px; height:197px; padding-top:20px;">
        <div style="float:left;width:22px; margin:50px 5px 0 10px; height:52px;"><img class="mylefter"
                                                                                      src="/public/src/images/lefter.png"/></div>
        <div style="width:903px; float:left;">
            <div class="banner" data-pointer="0" data-interval="6" data-item="2" data-small="3" data-middle="4"
                 data-big="5" data-style="border-red">
                <ul class="carousel">
                    <?php if($output['franchiserArticle']){
                        foreach($output['franchiserArticle'] as $tuijian){?>
                            <li class="item">
                                <div class="doc-carousel" style="text-align:center; margin-left:10px; margin-top:10px;">
                                    <a href="<?php echo urlShop('article','show',array('article_id'=>$tuijian['article_id'])) ?>">
                                        <img src="<?php echo UPLOAD_SITE_URL.'/shop/article/'.$tuijian['file_name'] ?>"/><span><?php echo $tuijian['franchisee_name'] ?></span>
                                    </a>
                                </div>
                            </li>
                       <?php }
                    }?>
                </ul>
            </div>
        </div>
        <div style="float:right;  margin:50px 10px 0 0px; width:22px; height:52px;"><img class="myrighter"
                                                                                         src="/public/src/images/righter.png"/>
        </div>
    </div>
</div>
<div class="blank"></div>
<script type="text/javascript">
    var franchiserList='',searchRes=$('#_stroelist>.list4_2');
    function jiameng_search(province,city) {
        var keyword= '',list=[];
        if(arguments.length==0){
            province=$('#search-province').val();
            city=$('#search-city').val();
            keyword= $.trim($('#search-keyword').val());
        }
        if(franchiserList&&(province||city||keyword.length)){
            searchRes.html('');
            list=$(franchiserList);
            searchRes.html((function(){
                var htmlStr='';
                list.each(function(_i,_item){
                    if(_item.nodeType!=1)return null;
                    if(keyword.length){
                        if(_item.getAttribute('data-title').indexOf(keyword)==-1)return null;
                    }else{
                        var isProvince=_item.getAttribute('data-province')==province;
                        var isCity=_item.getAttribute('data-city')==city;
                        var isAll=isProvince&&isCity;
                        if(!(isCity||isProvince)||(province&&city&&!isAll))return null;
                    }
                    htmlStr+="<div class='list4_2_1'>"+_item.innerHTML+"</div>";
                });
                return htmlStr;
            })());
        }
        return false;
    }
    $(function(){
        //初始化地区
        var map=$('#chinamap');
        franchiserList= $.trim(searchRes.html());
        function initArea(parentId){
            var province='',menglist_rows='';
            $.each(nc_a[parentId],function(_i,_item){
                if(_item[1]=='海外')return;
                province+='<option value="'+_item[0]+'">'+_item[1]+'</option>';
                if(parentId===0){
                    map.find("[data-name^='"+_item[1].substr(0,2)+"']").bind('click',function(){
                        jiameng_search(_item[0],0);
                    });
                    menglist_rows+='<a href="javascript:void(false);" onclick="jiameng_search('+_item[0]+')">'+_item[1]+'</a>';
                }
            });
            if(parentId===0){
                $("#menglist_rows").html(menglist_rows);
            }
            return province;
        }
        function initCity(provinceId){
            $('#search-city').html('<option value="">请选择城市</option>'+initArea(provinceId));
        }
        $('#search-province').append(initArea(0)).bind('change',function(){
            initCity($(this).val());
        });
        initCity(nc_a[0][0][0]);
    });
</script>
<script src="/public/src/js/shujian.js"></script>
<script type="text/javascript">
    $(function(){
        var franchiserurl = "/mobile/index.php?act=franchiser&op=franchiser_listall";
        $.ajax({
            url: franchiserurl,
            type: 'get',
            dataType: 'json',
            success: function (result) {
                var markers = new Array();
                var map = new BMap.Map("baidumap");
                var point = new BMap.Point(109.729099,34.993223);
                map.centerAndZoom(point, 5);
                if(result.datas)
                {
                    for(i=0;i<result.datas.length;i++)
                    {
                        var p = result.datas[i].mapPoint.split(',');
                        markers.push({marker:new BMap.Marker(new BMap.Point(p[0],p[1])),title:result.datas[i].franchisee_name,content:'<div style="margin:0;line-height:20px;padding:2px;">地址：'+
                        result.datas[i].franchisee_address+'<br/>联系人：'+result.datas[i].linkname+'<br/>电话：'+result.datas[i].linkname_mobile+
                        '<br/><button style="padding: 5px;"><a href="http://www.shujianhao.com/index.php?act=article&op=show&article_id='+(result.datas[i].article_id)+'">点击查看信息</a></button></div>'});
                    }

                }
                map.addControl(new BMap.NavigationControl());
                map.addControl(new BMap.GeolocationControl());


                for(var key in markers)
                {
                    markers[key].marker.num = key;
                    markers[key].marker.addEventListener("click",function(){

                        var searchInfoWindow = null;
                        map.centerAndZoom(markers[this.num].marker.getPosition(), 15);
                        map.panTo(markers[this.num].marker.getPosition());
                        searchInfoWindow = new BMapLib.SearchInfoWindow(map, markers[this.num].content, {
                            title  : markers[this.num].title,      //标题
                            width  : 200,             //宽度
                            height : 120,              //高度
                            panel  : "panel",         //检索结果面板
                            enableAutoPan : true,     //自动平移
                            searchTypes   :[
                                //从这里出发
                            ],
                            enableSendToPhone:false
                        });
                        searchInfoWindow.open(markers[this.num].marker);

                    },false);
                    map.addOverlay(markers[key].marker);
                }

            }

        });
    });

    function writeObj(obj){
        var description = "";
        for(var i in obj){
            var property=obj[i];
            description+=i+" = "+property+"\n";
        }
        alert(description);
    }
</script>